using System;

namespace Infinity.Common.Logger
{
	public abstract class TimeLoggerBase : LoggerBase
	{
		protected TimeLoggerBase()
		{
			LogTime = true;
			TimeFormat = "[HH:mm:ss]: ";
		}

		public virtual bool LogTime { get; set; }
		public virtual string TimeFormat { get; set; }

		protected abstract void Write(string text, bool logTime);

		protected virtual void WriteLine(string text, bool logTime)
		{
			Write(text + Environment.NewLine, logTime);
		}

		public override void Write(string text = "")
		{
			Write(text, true);
		}

		public override void WriteLine(string text = "")
		{
			WriteLine(text, true);
		}

		protected virtual string ToLogTime(string text)
		{
			if (LogTime)
				return string.Format("{0}{1}", DateTime.Now.ToString(TimeFormat), text);
			return text;
		}
	}
}